// test.ts  
import { v4 as uuidv4 } from "uuid";  
import { MockMethod, MockConfig } from "vite-plugin-mock";  
import Mock from "mockjs";  
  
const Random = Mock.Random;  
  
export default [  
  {  
    url: "/api/topic",  
    method: "get",  
    timeout: 1000,
    response: () => {  
      const dataList: any[] = [];  
      const count = 15; // 假设我们想要生成5个数据项  
  
      for (let i = 0; i < count; i++) {  
        dataList.push({  
          id: uuidv4(),  
          title: Random.cword(5, 25),  
          content: Random.cparagraph(),  
          timestamp: +new Date() - 120000, // 生成当前时间的时间戳  
          isRecommend: true,
          user: {  
            name: Random.cname(), // 生成随机中文名字  
            age: Random.integer(18, 60), // 生成18到60之间的随机整数  
            avatar: Random.image('200x200', '#4A7BF7', 'Hello'), // 生成随机图片URL  
          },  
        });  
      }  
      return {  
        code: 200,  
        message: "请求成功",  
        type: "success",  
        data: dataList,  
      };  
    },  
  },  
] as MockMethod[];